import java.io.*;
import java.util.Date;
import java.util.Calendar;

public class HolidayRequest{
//getters 

	private Date startDay;
	private Date endDay;
	private int driverId;

	public Date getStartDay(){
		return this.startDay;
	}

	public Date getEndDay(){
		return this.endDay;
	}

	public int getDriverId(){
	return this.driverId;
	}

	public HolidayRequest(Date startDay, Date endDay,int driverId){
		this.startDay=startDay;
		this.endDay=endDay;
		this.driverId=driverId;
	}

	public int getNumOfDays(){
		Calendar cal1=Calendar.getInstance();
		Calendar cal2=Calendar.getInstance();
		cal1.setTime(this.startDay);
		cal2.setTime(this.endDay);
		long d1=cal1.getTimeInMillis();
		long d2=cal2.getTimeInMillis();
		int diff=(int)((d2-d1)/1000/60/60/24);

		return diff;
	} 
	
public boolean validate(int H){
		if(getNumOfDays()<=0){
			//System.out.println("The dates you give are not valid");
			return false;
		}
		if((getNumOfDays() + H) >25 ){
			//System.out.println("More than 25");
			return false;
		}
		else
		  return true;
}
public void setDB(){
	int daysNum = getNumOfDays() + DriverInfo.getHolidaysTaken(this.driverId);
    int dNum=getNumOfDays();
	Calendar cal=Calendar.getInstance();
	cal.setTime(this.startDay);
	//long d=cal.getTimeInMillis();

	for(int i=0; i<dNum; i++){
	 cal.add(Calendar.DATE, 1);
   DriverInfo.setAvailable(this.driverId, cal.getTime(), false);
	}

	DriverInfo.setHolidaysTaken(this.driverId,daysNum);
}
}
